package sctu.edu.java.year2016.team04.luoxinghua.day20160601.chapter9_1;

/**
 * 创建一个类，并在类中创建一个成员内部类，通过成员内部类计算1到任意数的和的操作，并在外部类中进行测试。
 * Created by 落叶的思恋 on 2016/5/31.
 */
import java.util.Scanner;
public class Work91 {
    int num;

    Work91(int num) {//外部类的构造方法
        this.num = num;
    }

    class inside {//内部类
        int sum = 0;

        int add() {//内部类的方法
            for (int i = 0; i <= num; i++)
                sum = sum + i;
        return sum;}
    }

    public static void main(String[] args) {
 Scanner sc=new Scanner(System.in);
        int figure=sc.nextInt();
        System.out.println("Please enter the Numbers");
        Work91 work = new Work91(figure);
        Work91.inside in=work.new inside();
        System.out.println("1 到" + figure + "的和是" +in.add());

    }
}
